//
//  DCGisticsCell.m
//  Driver
//
//  Created by 大橙子 on 2018/11/7.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCGisticsCell.h"
@interface DCGisticsCell ()
@property (nonatomic,strong) UIImageView *circularView;
@property (nonatomic,strong) UILabel *contentLabel;
@property (weak,nonatomic)  UIView *bottomLineView;
@end
@implementation DCGisticsCell
+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *CellID = @"Cell";
    DCGisticsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (cell == nil) {
        cell = [[DCGisticsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        // 添加自己可能显示的所有子控件
        
        //中间的圆
        UIImageView *circularView = [[UIImageView alloc]init];
        circularView.image = IMAGENAME(@"choose");
        [self.contentView addSubview:circularView];
        self.circularView = circularView;

        self.contentLabel = [[UILabel alloc]init];
        self.contentLabel.font = [UIFont systemFontOfSize:13];
        self.contentLabel.textAlignment = NSTextAlignmentLeft;
        self.contentLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.contentLabel];
        
        //底部的线
        UIView *bottomLineView = [[UIView alloc]init];
        bottomLineView.backgroundColor = [UIColor lightGrayColor];
        bottomLineView.alpha = 0.8;
        [self.contentView addSubview:bottomLineView];
        self.bottomLineView = bottomLineView;
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.circularView.frame = CGRectMake(20, (self.height - 15)/2, 15, 15);
    self.contentLabel.frame = CGRectMake(self.circularView.right+10, 0, self.width - 30 - self.circularView.width, self.height);
    self.bottomLineView.frame = CGRectMake(self.circularView.x + self.circularView.width/2, self.circularView.bottom, 1, self.height - self.circularView.height);
}
-(void)setModel:(DCGisticsModel *)model
{
    _model = model;
    self.contentLabel.text = [NSString stringWithFormat:@"%@    %@",model.name,Str_IsEmpty(model.time)?@"":model.time];
    if (_model.isShow) {
        self.circularView.image = IMAGENAME(@"choose-selected");
        self.contentLabel.textColor = BlueColor;
    }else{
        self.circularView.image = IMAGENAME(@"choose");
        self.contentLabel.textColor = [UIColor lightGrayColor];
    }
    if (model.isBottomShow) {
        self.bottomLineView.hidden = NO;
    }
    else
    {
        self.bottomLineView.hidden = YES;
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
